package com.yuexinduo.education.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.yuexinduo.education.R;

public class PayBindingDialog extends Dialog implements View.OnClickListener {
    private Context mContext;
    private int type;
    private TextView dialogCancel;
    private TextView dialogSure;
    public OnClickListener listener;
    private LinearLayout dialogLinOne;
    private LinearLayout dialogLinTwo;
    private TextView dialogKnow;


    public PayBindingDialog(@NonNull Context context, int themeResId,int type) {
        super(context, themeResId);
        this.mContext=context;
        this.type=type;
    }

    public void setListener(OnClickListener listener) {
        this.listener = listener;
    }




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_pay_binding);

        dialogCancel = (TextView) findViewById(R.id.dialog_cancel);
        dialogSure = (TextView) findViewById(R.id.dialog_sure);
        dialogLinOne = (LinearLayout) findViewById(R.id.dialog_lin_one);
        dialogLinTwo = (LinearLayout) findViewById(R.id.dialog_lin_two);
        dialogKnow = (TextView) findViewById(R.id.dialog_know);

        dialogSure.setOnClickListener(this);
        dialogCancel.setOnClickListener(this);
        dialogKnow.setOnClickListener(this);

        if (type == 1){
            dialogLinOne.setVisibility(View.VISIBLE);
            dialogLinTwo.setVisibility(View.GONE);
        }else {
            dialogLinOne.setVisibility(View.GONE);
            dialogLinTwo.setVisibility(View.VISIBLE);
        }


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.dialog_cancel:
                dismiss();
                break;
            case R.id.dialog_sure:
                listener.onListener();
                dismiss();
                break;
            case R.id.dialog_know:
                dismiss();
                break;

        }
    }

    public interface  OnClickListener{
        void onListener();
    }
}
